#-*- coding:UTF-8 -*-
__author__ = 'Frank Yang <frankyang418@gmail.com>'
__date__ = "13-5-16 上午10:33"
__doc__ = u"表单基类"

from wtforms import Form as _Form
from lib.vendor.MultiValueDict import MultiValueDict


class BaseForm(_Form):
    u"""
    class LoginForm(BaseForm):
        uid = TextField(label=u"用户名", validators=[Required(u"用户名必须填写")])
        pwd = PasswordField(label=u"密码", validators=[Required(u"密码必须填写")])
    """

    def __init__(self, handler=None, obj=None, prefix='', formdata=None, **kwargs):
        if handler:
            formdata = MultiValueDict()
            for name in handler.request.arguments.keys():
                formdata.setlist(name, handler.get_arguments(name))
        _Form.__init__(self, formdata, obj=obj, prefix=prefix, **kwargs)